package com.ruoyi.documents.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.documents.domain.DocCompletion;
import com.ruoyi.documents.service.IDocCompletionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 竣工文件Controller
 * 
 * @author ruoyi
 * @date 2023-12-21
 */
@RestController
@RequestMapping("/documents/completion")
public class DocCompletionController extends BaseController
{
    @Autowired
    private IDocCompletionService docCompletionService;

    /**
     * 查询竣工文件列表
     */
    @PreAuthorize("@ss.hasPermi('documents:completion:list')")
    @GetMapping("/list")
    public TableDataInfo list(DocCompletion docCompletion)
    {
        startPage();
        List<DocCompletion> list = docCompletionService.selectDocCompletionList(docCompletion);
        return getDataTable(list);
    }

    /**
     * 导出竣工文件列表
     */
    @PreAuthorize("@ss.hasPermi('documents:completion:export')")
    @Log(title = "竣工文件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DocCompletion docCompletion)
    {
        List<DocCompletion> list = docCompletionService.selectDocCompletionList(docCompletion);
        ExcelUtil<DocCompletion> util = new ExcelUtil<DocCompletion>(DocCompletion.class);
        util.exportExcel(response, list, "竣工文件数据");
    }

    /**
     * 获取竣工文件详细信息
     */
    @PreAuthorize("@ss.hasPermi('documents:completion:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(docCompletionService.selectDocCompletionById(id));
    }

    /**
     * 新增竣工文件
     */
    @PreAuthorize("@ss.hasPermi('documents:completion:add')")
    @Log(title = "竣工文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DocCompletion docCompletion)
    {
        return toAjax(docCompletionService.insertDocCompletion(docCompletion));
    }

    /**
     * 修改竣工文件
     */
    @PreAuthorize("@ss.hasPermi('documents:completion:edit')")
    @Log(title = "竣工文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DocCompletion docCompletion)
    {
        return toAjax(docCompletionService.updateDocCompletion(docCompletion));
    }

    /**
     * 删除竣工文件
     */
    @PreAuthorize("@ss.hasPermi('documents:completion:remove')")
    @Log(title = "竣工文件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(docCompletionService.deleteDocCompletionByIds(ids));
    }
}
